from time import sleep

import pyautogui
import uiautomation
class Shenqingdan():
        his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
        his.SetFocus()
        xinzheng = his.CustomControl(AutomationId='recordView',ClassName='RecordEditView').ButtonControl(AutomationId='add_btn',ClassName='Button',Name='新增')



        shoushushenqingdan = his.WindowControl(ClassName='Window').GroupControl(ClassName='GroupBox',Name='录入区').TabControl(AutomationId='tabAll').TabItemControl(AutomationId='TABSSD',ClassName='TabItem',Nam='手术申请单')
        shoushushenqingmingcheng = shoushushenqingdan.PaneControl(ClassName='ScrollViewer').EditControl(AutomationId='PART_TextBox',ClassName='TextBox',foundIndex=3)
        shenqingzhixingkeshi =  shoushushenqingdan.PaneControl(ClassName='ScrollViewer').EditControl(AutomationId='PART_TextBox',ClassName='TextBox',foundIndex=2)
        shenqingzhudaoyishen  = shoushushenqingdan.PaneControl(ClassName='ScrollViewer').EditControl(AutomationId='PART_TextBox',ClassName='TextBox',foundIndex=6)
        shenqingmazhuifangshi = shoushushenqingdan.PaneControl(ClassName='ScrollViewer').ComboBoxControl(ClassName='ComboBox',foundIndex=3)
        quanshengmazhui = shenqingmazhuifangshi.ListItemControl(ClassName='ListBoxItem',foundIndex=2)


        shenqingdanchuangkou = his.WindowControl(ClassName='Window')
        baocun =shenqingdanchuangkou.GroupControl(ClassName='GroupBox',Name='操作区').ButtonControl(ClassName='Button',Name='保存')
        #点击手术手术申请单
        def click_sssqd(self):
                self.shoushushenqingdan.Click()
        #选择申请手术名称
        def choose_sssqmc(self,sssqmc):
                self.shoushushenqingmingcheng.Click()
                self.shoushushenqingmingcheng.SendKeys(sssqmc)
                sleep(1)
                pyautogui.press('enter')
        #选择申请执行科室
        def choose_sqzxks(self,sqzxks):
                self.shenqingzhixingkeshi.Click()
                self.shenqingzhixingkeshi.SendKeys(sqzxks)
                sleep(1)
                pyautogui.press('enter')
        #选择申请主刀医生
        def choose_sqzdys(self,sqzdys):
                self.shenqingzhudaoyishen.Click()
                self.shenqingzhudaoyishen.SendKeys(sqzdys)
                sleep(1)
                pyautogui.press('enter')
        #选择麻醉方式
        def choose_sqmzfs(self):
                self.shenqingmazhuifangshi.Click()
                self.quanshengmazhui.Click()
        #保存并关闭
        def save_close(self):
                self.baocun.Click()
                self.shenqingdanchuangkou.GetWindowPattern().Close()








